<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<script type="text/javascript">
window.onload = function (){
	fnTime();                       //马上显示无需等待
	setInterval(fnTime,1000);
	function fnTime(){
		var myTime = new Date();
		var iYear = myTime.getFullYear();       //哪年
		var iMonth = myTime.getMonth() + 1;       //几月
		var iDate = myTime.getDate();           //几号，一月为0
		var iWeek = myTime.getDay();            //星期几，星期天为0
		var iHours = myTime.getHours();
		var iMin = myTime.getMinutes();
		var iSec = myTime.getSeconds();
		var str = '';
		if (iWeek === 0) iWeek = '星期日';
		if (iWeek === 1) iWeek = '星期一';
		if (iWeek === 2) iWeek = '星期二';
		if (iWeek === 3) iWeek = '星期三';
		if (iWeek === 4) iWeek = '星期四';
		if (iWeek === 5) iWeek = '星期五';
		if (iWeek === 6) iWeek = '星期六';
		str = iYear+ '年' +iMonth+ '月' +iDate+ '日 ' + iWeek + ' ' +toTwo(iHours)+':'+toTwo(iMin)+':'+toTwo(iSec);
		document.body.innerHTML = str;
	} 
}
function toTwo(n){
	/*if (n<10) {
		return n = '0' + n;			//都是字符串
	}else{
		return n = '' + n;			//都是字符串
	};*/
	return n<10 ? '0'+n : ''+n;
}

</script>
<body>

</body>
</html>